package com.gupao.netty.bytebuf;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufUtil;

import java.nio.ByteBuffer;

public class ByteBufCreate {

    public static void main(String[] args) {

        ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer();
        printMsg(byteBuf);

    }

    public static void printMsg(ByteBuf buf){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("read index:").append(buf.readerIndex());
        stringBuilder.append("write index:").append(buf.writerIndex());
        stringBuilder.append("capacity:").append(buf.capacity());
        stringBuilder.append("maxCapacity:").append(buf.maxCapacity());
        ByteBufUtil.appendPrettyHexDump(stringBuilder,buf);

        System.out.println(stringBuilder.toString());
    }
}
